<?php require_once('../conn/DBconnect.php'); ?>		
	<div id="div-container">
		<div id="div-header">
			<div class="div-header-title">
				<div class="dh-title-left"></div>
				<div class="dh-title-center">Make a selection</div>
				<div class="dh-title-right"></div>
			</div>
		</div>
		<div id="div-content">
			<?php 
			
			$race_code = "";
			if (isset($_POST["r_race_code"])) 
			{
			    $race_code = $_POST["r_race_code"];
			}
			
			$raceCatSQL = "call sp_race('LIST','EVENT',1);";
	
			$result = mysqli_query($mysqlLink, $raceCatSQL);
			
			$isChecked = false;
			if($result->num_rows == 1)
				$isChecked = true;
						
			while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
				if($race_code == $row["race_code"]){
					$isChecked = true;
				}
			?>
			<div class="formItem">
				<div style="width:40px;"></div>
				<div><input type="radio" name="distance" value="<?php echo $row["race_code"]?>" <?php if($isChecked){ echo "checked"; $isChecked=false; }?>></div>
				<div class="formLabel"><?php echo $row["race_distance"]?> Run</div>
				<div class="formLabel">Php <?php echo $row["rc_reg_fee"]?></div>
			</div>
			<?php 
			}
			
			/* free result set */
			mysqli_free_result($result);
			
			/* close connection */
			mysqli_close($mysqlLink);
	
			?>
		</div>
	</div>
